package cl.sujey.utils;

public class StringUtils {

	/**
	 * This method is responsible for counting the number of a appearances given
	 * character in a given word.
	 * 
	 * oso omo ana anilinina
	 * 
	 * @param theWord
	 *            The word in which the character is searched in.
	 * @param theCharacter
	 *            The character searched in the word.
	 * @return The number of a appearances of the character in the word
	 */
	public static int countCharsIn(String theWord, String theCharacter) {

		int cantidad = 0;
		int ultimoIndice = 0;
		while (theWord.indexOf(theCharacter, ultimoIndice) != -1) {
			ultimoIndice = theWord.indexOf(theCharacter, ultimoIndice) + 1;
			cantidad++;
		}

		return cantidad;
	}

	/**
	 * This method is responsible for inverting a given word.
	 * 
	 * compareto() equals() equalsIgnorcase() substring() length() charAt()
	 * 
	 * @param aWord
	 *            The word to be inverted.
	 * @return The inverted word.
	 */
	public static String invert(String aWord) {
		
		/* El largo de la palabra */
		int largoPalabra  = aWord.length();
		String invertida = "";
		int indice = 0;
		
		while (indice < largoPalabra){
			
			/* Se recupera el caracter */
			char elCaracter = aWord.charAt(indice);
			
			invertida = elCaracter + invertida;
		
			indice++;
		}

		return "";
	}
	
	public static void main(String[] args) {
		invert("andres");
	}
}
